﻿<?php

class SettingForm extends Zend_Form
{
	public function __construct($options = NULL)
	{
		parent::__construct($options);
		$this->setName('SettingForm');
		
		//File loader
		$file = new Zend_Form_Element_File('file');

		//List of all results
		$resultsAll = new Zend_Form_Element_Multiselect('resultsAll');
		$resultsAll->setLabel('Все результаты')
					->setAttrib('size', 7);
		$label = $resultsAll->getDecorator('label');
    	$label->setOption('placement', 'append');			
		$resultstable = new ResultsTable();
		/*foreach ($resulttable->fetchAll() as $r){
			$resultsoptions = array(
			$r->id => $r->name);
		}*/
		$resultsAlloptions = $resultstable->fetchAll()->toArray();
		$resultsAll->setMultiOptions($resultsAlloptions);
		$resultsAll->addValidator('inArray', TRUE, array(array_keys($resultsAlloptions)));
		
		//Add button
		$addButton = new Zend_Form_Element_Button('addButton');
		$addButton->setLabel('->');
		
		//Remove button
		$removeButton = new Zend_Form_Element_Button('removeButton');
		$removeButton->setLabel('<-');
		
		//List of project's results
		$resultsProj = new Zend_Form_Element_Multiselect('resultsProj');
		$resultsProj->setLabel('Резултаты проекта')
					->setAttrib('size', 7);
		$resultsProjoptions = array('1','2');			
		$resultsProj->addMultiOptions($resultsProjoptions);			
		$label = $resultsProj->getDecorator('label');
    	$label->setOption('placement', 'append');
		
    	//Submit button
		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setLabel('Обновить');

		$this->addElements(array($file, $resultsAll, $resultsProj, $addButton, $removeButton, $submit));
	}
}